package flexo.file.writer;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import flexo.common.LogMsgType;
import flexo.file.Node;

public abstract class Writer
{
	protected void writeError(String file)
	{
		flexo.Kernel.log("flexo.graphic.reader.Writer", "Error while writing '" + file + "'", LogMsgType.ERROR);
	}
	
	protected BufferedWriter createBufferedWriter(String file)
	{		
		try
		{
			FileWriter f;
			f = new FileWriter(file);
			return new BufferedWriter(f);
		} 
		catch (IOException e)
		{
			flexo.Kernel.log("flexo.graphic.reader.Writer", "Couldn't create '" + file + "'", LogMsgType.WARNING);
			return null;
		}		
	}
	
	/**
	 * Write all the node structure to a file.
	 */
	public abstract void write (Node fileNode);
}
